<?php

namespace app\admin\model;

use think\Model;

class NewsContent extends Common
{
    protected $name = 'news_information';
    protected $autoWriteTimestamp = true;
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';


    public function getRecommendTxtAttr($value, $data)
    {
        $statuses = [
            1 => '否',
            2 => '是',
        ];
        return $statuses[$data['recommend']];
    }

    /**
     * 新闻关联的分类
     * @return \think\model\relation\BelongsTo
     */
    public function newsClass()
    {
        return $this->belongsTo('NewsClass', 'type_id');
    }

    /**
     * 新闻关联的封面图
     * @return \think\model\relation\BelongsToMany
     */
    public function imgFile()
    {
        return $this->belongsTo('Picture', 'img');
    }

    public function reImgFile()
    {
        return $this->belongsTo('Picture', 're_img', 'id');
    }

}
